//
//  HBChangePaw.m
//  HuoBao
//
//  Created by sky on 15/12/4.
//  Copyright © 2015年 jinxin. All rights reserved.
//

#import "HBChangePaw.h"
#import "HBModifyPwdFirstCtrl.h"

@interface HBChangePaw ()

@property (nonatomic, strong) UILabel *tradePwd;

@end

@implementation HBChangePaw

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

-(void)buildLayout{
    self.title = @"修改密码";
    NSArray *_arr = [NSArray array];
    if ([[HBLoginManager sharedHBLoginManager].currentUserInfo.tradingPwdStatus integerValue])
    {
        _arr = [[NSArray alloc]initWithObjects:@"修改登录密码",@"重置提现密码", nil];
    }
    else
    {
        _arr = [[NSArray alloc]initWithObjects:@"修改登录密码",@"设置提现密码", nil];
    }
//    NSArray *_arr = [[NSArray alloc]initWithObjects:@"修改登录密码",@"重置交易密码", nil];
    for (int i = 0; i < 2; i++) {
        UIButton *bgBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, i * (44 + .5) + 10, SCREEN_WIDTH, 44)];
        bgBtn.backgroundColor = [LCCommon getColor:@"37383d"];
        bgBtn.tag = 1000 + i;
        [bgBtn addTarget:self action:@selector(BtnPressToPush:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:bgBtn];
        
        UILabel *title = [self LabelWithRect:CGRectMake(15,bgBtn.origin.y + (44/2 - 16/2), SCREEN_WIDTH/2, 16) textColor:[LCCommon getColor:@"999999"] textstr:[NSString stringWithFormat:@"%@",[_arr objectAtIndex:i]] textfont:16 textstyle:NSTextAlignmentLeft];
        [self.view addSubview:title];
        if (i==1)
        {
            self.tradePwd = title;
        }
        
        UIImage *jiantou = [UIImage imageNamed:@"income_zhaiquan"];
        UIImageView *jintouvi = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH - 15 - jiantou.size.width,bgBtn.origin.y + (44/2 - jiantou.size.height/2), jiantou.size.width, jiantou.size.height)];
        jintouvi.image = jiantou;
        [self.view addSubview:jintouvi];
    }
    
    [[NSNotificationCenter defaultCenter]addObserverForName:@"UpDataInformation" object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
        if ([[HBLoginManager sharedHBLoginManager].currentUserInfo.tradingPwdStatus integerValue])
        {
            _tradePwd.text = @"重置提现密码";
        }
        else
        {
            _tradePwd.text = @"设置提现密码";
        }
    }];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    if ([[HBLoginManager sharedHBLoginManager].currentUserInfo.tradingPwdStatus integerValue])
    {
        _tradePwd.text = @"重置提现密码";
    }
    else
    {
        _tradePwd.text = @"设置提现密码";
    }
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter]removeObserver:self forKeyPath:@"UpDataInformation"];
}

-(void)BtnPressToPush:(UIButton *)sender{
    LLog(@"%ld",sender.tag);
    if (sender.tag==1000)
    {
        HBModifyPwdFirstCtrl *modifyCtrl = [[HBModifyPwdFirstCtrl alloc]init];
        modifyCtrl.modifyType = ModifyPwdType_LoginPwd;
        [self.navigationController pushViewController:modifyCtrl animated:YES];
    }
    else
    {
        HBModifyPwdFirstCtrl *modifyCtrl = [[HBModifyPwdFirstCtrl alloc]init];
        modifyCtrl.modifyType = ModifyPwdType_BuyPwd;
        [self.navigationController pushViewController:modifyCtrl animated:YES];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(UILabel *)LabelWithRect:(CGRect)rect textColor:(UIColor *)color textstr:(NSString *)str textfont:(int)font textstyle:(NSTextAlignment)aligment{
    UILabel *label = [[UILabel alloc] initWithFrame:rect];
    label.textColor = color;
    label.text = str;
    label.font = [UIFont systemFontOfSize:font];
    label.textAlignment = aligment;
    label.numberOfLines = 0;
    return label;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
